import pickle
from selenium import webdriver
import time
import random
import urllib3
import logging
import demjson
import os
import sys

logging.basicConfig(level=logging.INFO,format='%(asctime)s -%(levelname)s -%(process)d -%(module)s -%(funcName)s -%(message)s')
def getAnswerJson(p,s):
    url="http://xf.faxuan.net/ess/service/getpaper?paperId=%s&series=%s_answer"%(p,s)
    logging.info(url)
    http = urllib3.PoolManager()
    r = http.request(
        'GET',
        url
    )
    da = r.data
    da=da.decode("utf-8")
    das=da.split("\r\n")
    logging.info("read xhr data:%s"%(da))
    if(len(das) <3 ):
        logging.warning("xhr read error!")
        return None
    else:
        try:
            getjson = demjson.decode(das[2])
        except:
            logging.warning("json解析错误")
            return None
        else:
            return getjson

print(getAnswerJson('2163','18')[0]['answerNo'])
print('ABCED'.find('E'))